package com.woniuxy.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.woniuxy.entity.Allocation;
import com.woniuxy.service.AllocationService;

@RestController //所有数据默认以json返回
@RequestMapping("/allocation")
public class AllocationController {
	@Autowired
	private AllocationService allocationService;
	
	@GetMapping("/find")
	public List<Allocation> findAllocation() {
		return allocationService.findAllocation();
	}
	@RequestMapping("/detail")
	public List<Allocation> findAllocationDeatilById(String aorder) {
		return allocationService.findAllocationById(aorder);
	}
	
	@RequestMapping("/insert")
	public String inserAllocation(Allocation allocation){
		int i=allocationService.insertAllocation(allocation);
		if (i==1) {
			return "success";
		}else{
			return "false";
		}
	}
	
	@RequestMapping("/delete")
	public String deleteAllocationById(String aorder) {
		int i=allocationService.deleteAllocationById(aorder);
		if (i==1) {
			return "success";
		}else{
			return "false";
		}
	}
}
